package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.common.domain.query.PageQuery;
import com.tianji.learning.domain.dto.LearningPlanDTO;
import com.tianji.learning.domain.vo.LearningLessonVO;
import com.tianji.learning.domain.vo.LearningPlanPageVO;
import com.tianji.learning.service.LearningLessonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description LessonsController
 * @Author WJH
 * @Date 2024-12-07
 */


@RestController
@RequestMapping("/lessons")
@Api(tags = "我的课表")
public class LearningLessonsController {

    @Autowired
    private LearningLessonService learningLessonService;

    @GetMapping("/page")
    @ApiOperation("分页查询我的课表")
    public PageDTO<LearningLessonVO> getPage(PageQuery pageQuery){
        return learningLessonService.getPage(pageQuery);
    }

    @GetMapping("/now")
    @ApiOperation("查询正在学习的课程")
    public LearningLessonVO getMyLesson(){
        return learningLessonService.getMyLesson();
    }

    @GetMapping("/{courseId}")
    @ApiOperation("根据id查询某课程学习状态")
    public LearningLessonVO getCourseById(@PathVariable Long courseId){
        return learningLessonService.getCourseById(courseId);
    }

    @PostMapping("/plans")
    @ApiOperation("创建学习计划")
    public void plans(@RequestBody LearningPlanDTO learningPlanDTO){
        learningLessonService.plans(learningPlanDTO);
    }

    @ApiOperation("查询我的学习计划")
    @GetMapping("/plans")
    public LearningPlanPageVO queryMyPlans(PageQuery query){
        return learningLessonService.queryMyPlans(query);
    }

}
